# def show():
#     print("hogwarts")  # 函数体
# print(show())  # 调用函数

# def get_number():
#     num = input("请输入一个整数：")
#     if num.isdigit():
#         num = int(num)
#     else:
#          num = None
#     return num
# print(get_number()) # 定义有返回值的函数

# # 计算两个值的和
# def add(a, b):
#     '''
#     计算两个值的和
#     :param a: 第1个数
#     :param b: 第2个数
#     :return: 2个数的和
#     '''
#     return a + b
# # 调用函数
# print(add(1, 2))

# # 函数返回多个值
# def get_two_number():
#     '''
#     用户输入得到两个整数
#     :return: 两个整数的值
#     '''
#     num1 = input("请输入第一个整数：")
#     num2 = input("请输入第一个整数：")
#     return num1, num2
# # print(get_two_number())
# num1, num2 = get_two_number()
# print(num1, num2)

# # 组包
# nums = 1, 2, 3, 4, 5
# print(nums)
# print(type(nums))
#
# # 解包
# a, b, c, d, e = nums
# print(a, b, c, d, e)

# def multi_return(num):
#     '''
#     不同条件下的多个返回值
#     :return:
#     '''
#     if num == 0:
#         return False
#     else:
#         return num
# print(multi_return(9))

  # 位置参数
# def printMsg(n, msg):
#     for i in range(n):
#         print(f'第{i+1}次输出{msg}')
# printMsg(5, "Hogworts")
# # 关键字参数
# printMsg(n=5, msg="Hogworts")
# printMsg(msg="Hogworts", n=5)

# # 实现一个乘方函数
# def my_power(m, n=2):
#     return m ** n
# # 使用指定的参数
# print(my_power(2, 3))
# # 使用默认值参数
# print(my_power(2))
# def show(a, b, c=2):
#     print(a, b, c)  # 默认值参数  必须放在所有未指定默认值参数的后面
# print(show(2,1,2))

# 可变位置参数
# def my_sum(*args):
#     '''
#     不确定个数数字求和
#     :param args: 接受任意个数的参数
#     :return:
#     '''
#     print(args)
#     print(*args)  # 将接收到的任意多个实际参数放到一个元组中
#     print(type(args))
#     s = 0  # 局部变量
#     for i in args:
#         s += i
#         return s
# print(my_sum(1,2,3,4,5))

# 不确定的关键字参数
# def print_info(**kwargs):
#     print(kwargs)
#     print(type(kwargs))
#     for k,v in kwargs.items():
#         print(k, v)
# print_info(name="ww", age=18, gender="female")
# print_info(Tom=18, Jim=20, Lily=12)
# print_info(name="tom",age=22,gender="male",address="BeiJing")

# def info(name1, name2, *args, age1=18, age2=21, **kwargs):
#     print("Positional Arguments:")
#     print("name1:", name1)
#     print("name2:", name2)
#     print("args:", args)
#     print("Keyword Arguments:")
#     print("age1:", age1)
#     print("age2:", age2)
#     print("kwargs:", kwargs)

# info("Alice", "Bob", "Charlie", "Dave", age2=30, occupation="Engineer", city="New York")
# info("Alice", "Bob", "Charlie", "Dave", age1=25, age2=30, occupation="Engineer", city="New York")

# # 全局变量定义
# m = 20
# def show1():
#     # 使用全局变量
#     print("show1:", m)
# # 使用全局变量
# print(m)
# show1()

# 全局变量定义
m = 10
def show():
    # 局部变量与全局变量同名
    global m  # 函数内部修改全局变量的值
    m = "ABC"
    # 使用局部变量
    print("show:", m)
# 使用全局变量
show()
print(m)





